using GraphProcessor;
using IQIGame.Onigao.Logic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
	[System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.ChangeEntityAudio, typeof(LevelServiceGraph))]
    public partial class LevelServiceExecutionNode_ChangeEntityAudio : LevelServiceExecutionNode
    {
		protected override ServiceExecutionType mServiceType => ServiceExecutionType.ChangeEntityAudio;
        public override string name => LevelEditorConst.ChangeEntityAudio;
		
# region property
        [Output("目标", false)] public EditorLevelServiceTargetSetter tagOrMcid;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.ChangeEntityAudio, "Audio表ID(0为停止)")]
        public int loopAudioCid;
# endregion property
		protected override LevelServiceCustomConfig CreateConfig()
        {
        	LevelServiceExecutionCustom_ChangeEntityAudio rConfig;
# region CreateConfig
            rConfig = new LevelServiceExecutionCustom_ChangeEntityAudio
            {
                loopAudioCid = this.loopAudioCid,
            };
            this.tagOrMcid = new EditorLevelServiceTargetSetter((x) => rConfig.tagOrMcid = x);
# endregion CreateConfig
            return rConfig;
        }

        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
# region OnSync
            if (tempNode is LevelServiceExecutionNode_ChangeEntityAudio rNode)
            {
                this.loopAudioCid = rNode.loopAudioCid;
            }
            if (newConfig.customConfig is LevelServiceExecutionCustom_ChangeEntityAudio rConfig)
            {
                this.SyncTarget(rConfig.tagOrMcid, nameof(tagOrMcid));
            }
# endregion OnSync
        }
    }
}